package cn.com.zs.android.model;

import cn.com.zs.android.util.Constants;
import cn.com.zs.android.util.NumberUtil;

/**
 * 手机屏幕像素设置
 * @author 曾帅
 */
public class PhoneParams {

	public final static int default_width = 800;
	public final static int default_height = 480;
	
	public static int width = default_width;
	public static int height = default_height;
	
	/**
	 * 以default_width, default_height为基准动态的得到地洞坐标
	 * @param width
	 * @param height
	 * @return
	 */
	public static int[] getPlaceByHole(int width, int height) {
		int[] holePlace = {
				getWidthSize(width), getHeightSize(height),
				getWidthSize(width)  + Constants.IMAGE_WIDTH,
				getHeightSize(height) + Constants.IMAGE_HEIGHT };
		return holePlace;
	}
	
	public static int[] getPlaceByGameOver(int width, int height) {
		int[] holePlace = {
				getWidthSize(width), getHeightSize(height),
				getWidthSize(width)  + Constants.GAME_OVER_WIDTH,
				getHeightSize(height) + Constants.GAME_OVER_HEIGHT };
		return holePlace;
	}
	
	/**
	 * 根据基准参数得到该手机应处理的数值
	 */
	public static int getWidthSize(int size) {
		return getSize(PhoneParams.default_width, PhoneParams.width, size);
	}
	
	public static int getHeightSize(int size) {
		return getSize(PhoneParams.default_height, PhoneParams.height, size);
	}
	
	public static int getSize(int defaultNumber, int number, int size) {
		Double tempPlace = (double) defaultNumber / (double) size;
		tempPlace = (double) number / (double) tempPlace;
		tempPlace = NumberUtil.round(tempPlace, 0);
		return tempPlace.intValue();
	}
}
